package io.renren.com.qywt.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.commons.mybatis.service.impl.CrudServiceImpl;
import io.renren.com.qywt.dao.AftersaleReturnGoodDao;
import io.renren.com.qywt.dto.AftersaleReturnGoodDTO;
import io.renren.com.qywt.entity.AftersaleReturnGoodEntity;
import io.renren.com.qywt.service.AftersaleReturnGoodService;
import io.renren.commons.security.context.TenantContext;
import io.renren.commons.security.user.SecurityUser;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;

/**
 * 仓库退货表
 *
 * @author jiaohj 15110414840@139.com
 * @since 3.0 2022-09-22
 */
@Service
public class AftersaleReturnGoodServiceImpl extends CrudServiceImpl<AftersaleReturnGoodDao, AftersaleReturnGoodEntity, AftersaleReturnGoodDTO> implements AftersaleReturnGoodService {

    @Override
    public QueryWrapper<AftersaleReturnGoodEntity> getWrapper(Map<String, Object> params){
        QueryWrapper<AftersaleReturnGoodEntity> wrapper = new QueryWrapper<>();

        String deliveryNo = (String)params.get("deliveryNo");
        wrapper.eq(StringUtils.isNotBlank(deliveryNo), "delivery_no", deliveryNo);
        String customerName = (String)params.get("customerName");
        wrapper.like(StringUtils.isNotBlank(customerName), "customer_name", customerName);
        String platformNo = (String)params.get("platformNo");
        wrapper.eq(StringUtils.isNotBlank(platformNo), "platform_no", platformNo);
        String prodSku = (String)params.get("prodSku");
        wrapper.eq(StringUtils.isNotBlank(prodSku), "prod_sku", prodSku);
        String prodName = (String)params.get("prodName");
        wrapper.like(StringUtils.isNotBlank(prodName), "prod_name", prodName);
        wrapper.eq("tenant_code", TenantContext.getTenantCode(SecurityUser.getUser()));
        return wrapper;
    }
}